home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / chelp.fpl < prev    next >
Text File  |  1995-08-22  |  3KB  |  109 lines

  1. /*
  2.  * CHelp script for FrexxEd - Lookup keywords in includes and
  3.  * autodocs using CHelp.
  4.  *
  5.  * Written by Mathias Axelsson 940209
  6.  * Updated 940924 to work without any external ARexx script
  7.  * Updated July '95 to add a lot of features that Niclas
  8.  * Angare suggested. Also added setup possibilities for
  9.  * CHelp.
  10.  *
  11.  */
  12.  
  13. export CHelp_lookup()
  14. {
  15.     string a, res, oldfact, outfile, newoutfile, cmd;
  16.     int newid, oldid, res1, env;
  17.     
  18.     env = ReadInfo("CHelp_activation");
  19.     
  20.     oldfact = ReadInfo("fact");
  21.     if (FACTCreate("chelp") < 0)
  22.         Request("Couldn't create locale FACT!", "", "OK");
  23.     
  24.     if (FACT("chelp", '.', 'W') < 0)
  25.         Request("Couldn't change . FACT!","","OK");
  26.     if (FACT("chelp", '_', 'W') < 0)
  27.         Request("Couldn't change _ FACT!","","OK");
  28.     
  29.     SetInfo(-1, "fact", "chelp");
  30.  
  31.     a = GetWord();
  32.     
  33.     SetInfo(-1, "fact", oldfact);
  34.     FACTDelete("chelp");
  35.     
  36.     if (strlen(a) == 0)
  37.     {
  38.         a = PromptString("", "Request", "Please enter lookup keyword");
  39.         if (strlen(a) == 0)
  40.             return;
  41.     }
  42.     
  43.     if (!FindPort("CHELP1", 10))
  44.         if (System("run >NIL: CHelp -s", "", "") == -1)
  45.             Request("Couldn't start Chelp!", "Error!", "OK");
  46.     
  47.     if (!FindPort("CHELP1", 10))
  48.         return;
  49.     
  50.     res1 = ReadInfo("CHelp_lookup_case");
  51.     if (res1 == 0)
  52.         cmd = "lookup ";
  53.     else
  54.         cmd = "clookup ";
  55.     
  56.     res = ARexxSend("CHELP1", joinstr(cmd, a), 60);
  57.     if (!strcmp(res, "1"))
  58.     {
  59.         oldid = GetEntryID();      /* Save current view id */
  60.         newid = New();                  /* Create new view */
  61.         
  62.         Activate(newid, -1, newid);    /* Split current view into two parts */
  63.         CurrentBuffer(newid);      /* Activate new view */
  64.         
  65.         SetInfo(newid, "tab_size", 8);
  66.         
  67.         res = ARexxSend("CHELP1", "GETVAR OUTPUTFILE", 60);
  68.         if (!strlen(res))
  69.             outfile = "T:chelp.lup";
  70.         else
  71.             outfile = res;
  72.         
  73.         newoutfile = ReadInfo("CHelp_outdir");
  74.         if (!strlen(newoutfile))
  75.             newoutfile = Stcgfp(outfile);
  76.         
  77.         newoutfile = newoutfile+a+".lup";
  78.         
  79.         if (System("copy "+outfile+" "+newoutfile, "", "") == -1)
  80.             Load(outfile);        /* Load original lookup file into view */
  81.         else
  82.             Load(newoutfile);    /* Load renamed lookup file into view */
  83.         
  84.         System("delete >NIL: "+outfile, "", "");
  85.         
  86.         if (env == 1)
  87.             CurrentBuffer(oldid);      /* Activate old view */
  88.     }
  89.     else
  90.         ARexxSend("CHELP1", "DISPBEEP", 60);
  91. }
  92.  
  93. void export CHelpPrefs()
  94. {
  95.   PromptInfo(-1,"CHelp preferences",-1,-1,
  96.     "CHelp_activation",
  97.     "CHelp_lookup_case",
  98.     "CHelp_outdir"
  99.    );
  100. }
  101.  
  102. ConstructInfo("CHelp_activation", "", "", "GWHC", "New|Old", 0, 0, "Old");
  103. ConstructInfo("CHelp_lookup_case", "", "", "GWCH", "Don't_care|Case_sensitive", 0, 0, "Don't_care");
  104. ConstructInfo("CHelp_outdir", "", "", "GWSH", "", 0, 0, "T:");
  105.  
  106. // CHelp Program menu
  107. MenuAdd("s", "CHelp...", "CHelpPrefs();", "", 6, 6, -1);
  108. MenuBuild();
  109.